package com.cy.embeddingdemo.schedule;


import com.cy.embeddingdemo.service.TaskManagerService;
import com.cy.embeddingdemo.util.RedisUtil;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;

@Service
public class ListenMinerUTask {

    @Autowired
    private RedisUtil redisUtil;


    @Resource
    private TaskManagerService taskManagerService;


    @Scheduled(fixedRate = 5000)
    public void pollTaskStatus() throws IOException, InterruptedException {
        Iterable<String> taskIds = redisUtil.getAllTaskIds();

        for (String taskId : taskIds) {
            taskManagerService.checkTaskStatus(taskId);
        }
    }

}
